package yunplus.io.hchome.presenter.implement;

import android.app.Activity;
import android.util.Log;

import com.alibaba.fastjson.JSONObject;

import java.util.Map;

import yunplus.io.hchome.display.view.ILaunchView;
import yunplus.io.hchome.display.view.IWebAppView;
import yunplus.io.hchome.model.storage.DomainShared;
import yunplus.io.hchome.model.storage.LoginShared;
import yunplus.io.hchome.presenter.contract.ILaunchPresenter;
import yunplus.io.hchome.presenter.contract.IWebappPresenter;

/**
 * Created by yfsoft on 2016/12/16.
 */

public class WebappPresenter implements IWebappPresenter {

    private final static String TAG = "WebappPresenter";

    private Activity _mActivity;

    private IWebAppView _mView;

    public WebappPresenter(Activity activity, IWebAppView view) {
        _mActivity = activity;
        _mView = view;
    }

    @Override
    public void logout() {
        DomainShared.removeDomain(_mActivity);
        _mView.logout();
    }

    @Override
    public void load() {
        JSONObject user = LoginShared.getUser(_mActivity);
        if(null == user){
            _mView.onLoaded();
        }else{
            _mView.onLoaded(user);
        }

    }
}
